﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Cofe.Core.Property
{
    public interface IPropertyInvoker
    {
        /// <summary>
        /// Create a task that Invoke a task in the property pair asynchronously and ensure there's no error.
        /// </summary>
        /// <typeparam name="T">Type of output</typeparam>
        /// <param name="ppair">Func&lt;ParameterDic, Task&lt;T&gt;&gt; or Func&lt;ParameterDic, T&gt; ppair</param>
        /// <param name="parameters">Dictionary that store running parameters.</param>
        /// <returns></returns>
        Task<T> InvokeAsync<T>(PropertyPair ppair, ParameterDic parameters = null, TaskScheduler taskScheduler = null);

        /// <summary>
        /// Create a task that Invoke a task in the property pair asynchronously and ensure there's no error.
        /// </summary>
        /// <param name="ppair">Func&lt;ParameterDic, Task&gt; or Action&lt;ParameterDic&gt; ppair</param>
        /// <param name="parameters">Dictionary that store running parameters.</param>
        /// <returns></returns>
        Task InvokeAsync(PropertyPair ppair, ParameterDic parameters = null, TaskScheduler taskScheduler = null);

        /// <summary>
        /// Invoke an action in the property pair synchronously, ensure no error and return the result.
        /// </summary>
        /// <typeparam name="T">Type of output</typeparam>
        /// <param name="ppair">Func&lt;ParameterDic, Task&lt;T&gt;&gt; or Func&lt;ParameterDic, T&gt; ppair</param>
        /// <param name="parameters">Dictionary that store running parameters.</param>
        /// <returns></returns>
        T Invoke<T>(PropertyPair ppair, ParameterDic parameters = null);

        /// <summary>
        ///  Invoke an action in the property pair synchronously and ensure no error.
        /// </summary>
        /// <param name="ppair">Func&lt;ParameterDic, Task&gt; or Action&lt;ParameterDic&gt; ppair</param>
        /// <param name="parameters">Dictionary that store running parameters.</param>
        void Invoke(PropertyPair ppair, ParameterDic parameters = null);
    }
}
